/***
 * 队列实现
 */
class Queue {
    constructor() {
      this.queue = []
    }

    size(){
        return this.queue.length
    }

    head(){
        return this.queue[0]
    }

    rear(){
        const length = this.queue.length
        return this.queue[length - 1]
    }
    /**
     * 入队:对尾添加
     * @param item
     */
    enqueue(item){
        this.queue.push(item)
    }

    /**
     * 出队：队头删除
     */
    dequeue(){
        this.queue.shift()
    }

    isEmpty(){
        return this.queue.length === 0
    }

    clear(){
        this.queue = []
    }

}
